package com.jk.vehicle.mini.constant;

/**
 * 常用是否枚举
 */
public enum IsOrNotEnum {
    /**
     * 否
     */
    NO((byte)0, "否"),

    /**
     * 是
     */
    YES((byte)1, "是");

    private Byte code;

    private String name;

    private IsOrNotEnum(Byte code, String name) {
        this.code = code;
        this.name = name;
    }

    public Byte getCode() {
        return code;
    }

    public void setCode(Byte code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据CODE获取枚举实例
     * @param code 枚举编号
     * @return 枚举实例
     */
    public static IsOrNotEnum getEnum(Byte code){
        for(IsOrNotEnum animal: IsOrNotEnum.values()){
            if(animal.code.equals(code)){
                return animal;
            }
        }
        return null;
    }
}
